package com.blockchain.console.servlets;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blockchain.framework.config.service.VariableManage;
import com.blockchain.framework.http.session.Session;
import com.blockchain.framework.service.ServiceSession;

public class Logout extends AbstractConsoleServlet {

	private static final long serialVersionUID = 1L;

	@Override
	protected void processGet(HttpServletRequest request,
			HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		processPost(request, response, serviceSession);
	}

	@Override
	protected void processPost(HttpServletRequest request,
			HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		Session session = serviceSession.getSession();
		if (session != null) {
			session.invalidate(request, response);
		}
		VariableManage manager = serviceSession.getService(VariableManage.class);
		String value = manager.getProperty("SYSTEM.AMDIN.KEY");
		String url = manager.getProperty("SYSTEM.AMDIN.URL");
		sendRedirect(request, response,
		url+"/admin?key="+value);
	}

}
